package com.fire.market.controller;


import com.fire.component.dto.Response;
import com.fire.component.dto.SingleResponse;
import com.fire.component.extension.Assert;

import com.fire.market.gateway.api.request.UserLoginParam;
import com.fire.market.gateway.api.request.UserRegisterParam;
import com.fire.market.entity.UserInfoDo;

import com.fire.market.service.impl.UserCmdCoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("user/cmd")
@Api(tags = "用户cmd操作")
public class UserCmdController extends BaseController{
    @Resource
    private UserCmdCoreService userCmdCoreService;

    @PostMapping(value = "register")
    @ApiOperation(value = "用户注册的详细信息", notes = "用户注册")
    public Response register(@RequestBody UserRegisterParam param){
        Assert.notNull(param,"UserRegisterParam is null");
        userCmdCoreService.register(param);
        return Response.buildSuccess();
    }

    @PostMapping(value = "login")
    @ApiOperation(value = "用户登录的详细信息", notes = "用户登录")
    public SingleResponse<UserInfoDo> login(@RequestBody UserLoginParam param){
        Assert.notNull(param, "UserLoginParam is null");
        return SingleResponse.of(userCmdCoreService.login(param));
    }
}
